<template>
  <!-- 总统计页 -->
  <view class="page-statistics tab-bar-page">
    <view
      class="topBar topBarNav"
    >
      <page-meta :root-font-size="fontsize+'px'"></page-meta>
      <view 
        class="title-nav"
        :style="{
          'padding-top': `${statusBar}px`,
          'text-align': 'center'
        }"
      >
        {{ `${getLanguageText('当前', AppSetting.language)} 第${AppSetting.periodsNum}期` }}
      </view>
    </view>
    <!-- 期数选择 -->
    <view class="page-nav" :style="{'margin-top': '5rem', 'display': 'flex'}">
      <span class="expalin" style="line-height: 1.4rem;">{{getLanguageText('选中期数', AppSetting.language)}}：</span>
      <view class="optionBar">
        <view 
          class="optionItem"
          :class="{'select': search.periodsNum == v.value}"
          v-for="(v, i) in periodsNumRange" :key="i"
          :value="v.value"
          @click="periodsNumChange(v.value)"
        >
          {{ v.text }}
        </view>
      </view>
    </view>
    <!-- 金额统计, 中奖统计 tab -->
    <flex class="page-nav tab-bar" justify="space-between">
      <flex class="tab-item" justify="center" :class="{ tabselect: tabselect == 1 }" @click.native="tabselect = 1">
        {{ getLanguageText('金额统计', AppSetting.language)}}
      </flex>
      <flex class="tab-item" justify="center" :class="{ tabselect: tabselect == 2 }" @click.native="tabselect = 2">
        {{ getLanguageText('中奖统计', AppSetting.language )}}
      </flex>
    </flex>
    <!-- 金额统计 -->
    <template v-if="tabselect == 1">
      <view class="page-nav">
        <view 
          class="page-nav" 
          v-if="orderSelectList && orderSelectList.winningNumber && orderSelectList.winningNumber.length == 3"
        >
          <view class="page-label">{{getLanguageText('小标统计', AppSetting.language)}}</view>
          <flex class="uni-form-item uni-column" justify="space-between">
            <view class="uni-label">{{getLanguageText('二位下单节数', AppSetting.language)}}: </view>
            <view class="uni-input-text">{{ twoSingleSectionsOrderNum }}</view>
          </flex>
          <flex class="uni-form-item uni-column" justify="space-between">
            <view class="uni-label">{{getLanguageText('二位总金额', AppSetting.language)}}: </view>
            <view class="uni-input-text">￥{{ twoSingleSectionsOrderMoney }}</view>
          </flex>
          <flex class="uni-form-item uni-column" justify="space-between">
            <view class="uni-label">{{getLanguageText('佣金比例', AppSetting.language)}}: </view>
            <view class="uni-input-text">{{ orderSelectList.commissionRate * 100 }}%</view>
          </flex>
          <flex class="uni-form-item uni-column" justify="space-between">
            <view class="uni-label">{{getLanguageText('佣金', AppSetting.language)}}: </view>
            <view class="uni-input-text">
              ￥{{ (twoSingleSectionsOrderMoney * orderSelectList.commissionRate).toFixed(2) }}
            </view>
          </flex>
          <view class="page-label">{{getLanguageText('大标统计', AppSetting.language)}}</view>
          <flex class="uni-form-item uni-column" justify="space-between">
            <view class="uni-label">{{getLanguageText('四位下单节数', AppSetting.language)}}: </view>
            <view class="uni-input-text">{{ fourSingleSectionsOrderNum }}</view>
          </flex>
          <flex class="uni-form-item uni-column" justify="space-between">
            <view class="uni-label">{{getLanguageText('四位总金额', AppSetting.language)}}: </view>
            <view class="uni-input-text">￥{{ fourSingleSectionsOrderMoney }}</view>
          </flex>
          <flex class="uni-form-item uni-column" justify="space-between">
            <view class="uni-label">{{getLanguageText('佣金比例', AppSetting.language)}}: </view>
            <view class="uni-input-text">{{ orderSelectList.commissionRate * 100 }}%</view>
          </flex>
          <flex class="uni-form-item uni-column" justify="space-between">
            <view class="uni-label">{{getLanguageText('佣金', AppSetting.language)}}: </view>
            <view class="uni-input-text">
              ￥{{ (fourSingleSectionsOrderMoney * orderSelectList.commissionRate).toFixed(2) }}
            </view>
          </flex>
          <view class="page-label">{{getLanguageText('总计', AppSetting.language)}}</view>
          <flex class="uni-form-item uni-column" justify="space-between">
            <view class="uni-label">{{getLanguageText('总销售金额', AppSetting.language)}}: </view>
            <view class="uni-input-text">
              ￥{{ twoSingleSectionsOrderMoney + fourSingleSectionsOrderMoney }}
            </view>
          </flex>
          <!-- <flex class="uni-form-item uni-column" justify="space-between">
            <view class="uni-label">当期中奖总金额: </view>
            <view class="uni-input-text">
              ￥{{ (fourSingleSectionsWinMoney + twoSingleSectionsWinMoney).toFixed(2) }}
            </view>
          </flex> -->
          <flex class="uni-form-item uni-column" justify="space-between">
            <view class="uni-label">{{getLanguageText('总佣金', AppSetting.language)}}: </view>
            <view class="uni-input-text">
              ￥{{ ((twoSingleSectionsOrderMoney + fourSingleSectionsOrderMoney) * orderSelectList.commissionRate).toFixed(2) }}
            </view>
          </flex>
          <flex class="uni-form-item uni-column" justify="space-between">
            <view class="uni-label">{{getLanguageText('今期应收', AppSetting.language)}}: </view>
            <view class="uni-input-text">
              ￥{{ ((twoSingleSectionsOrderMoney + fourSingleSectionsOrderMoney) * orderSelectList.commissionRate).toFixed(2) }}
            </view>
          </flex>
          <flex class="uni-form-item uni-column" justify="space-between">
            <view class="uni-label">{{getLanguageText('今期盈亏', AppSetting.language)}}: </view>
            <view class="uni-input-text">
              ￥{{ ((twoSingleSectionsOrderMoney + fourSingleSectionsOrderMoney).toFixed(2) - ((twoSingleSectionsOrderMoney + fourSingleSectionsOrderMoney) * orderSelectList.commissionRate).toFixed(2) - (fourSingleSectionsWinMoney + twoSingleSectionsWinMoney).toFixed(2)).toFixed(2) }}
              <!-- ￥{{ ((twoSingleSectionsOrderMoney + fourSingleSectionsOrderMoney).toFixed(2) - ((twoSingleSectionsOrderMoney + fourSingleSectionsOrderMoney) * orderSelectList.commissionRate).toFixed(2)).toFixed(2) }} -->
            </view>
          </flex>
        </view>
        <view v-else>
          请先在设置页面完成本期的中奖录入，金额统计方能正常计算
        </view>
      </view>
    </template>
    <!-- 中奖统计 -->
    <template v-if="tabselect == 2">
      <view 
        class="page-nav" 
        v-if="orderSelectList.winningNumber && orderSelectList.winningNumber.length == 3"
      >
        <flex class="uni-form-item uni-column" justify="space-between">
          <view class="uni-label">{{ getLanguageText('期数', AppSetting.language) }}：</view>
          <view class="uni-input-text">
            ￥{{ fourSingleSectionsWinMoney + twoSingleSectionsWinMoney }}
          </view>
        </flex>
        <flex class="uni-form-item uni-column" justify="space-between">
          <view class="uni-label">{{ getLanguageText('当期开奖号码', AppSetting.language) }}：</view>
          <view class="uni-input-text">
            <view 
              v-for="(v, i) in orderSelectList.winningNumber" :key="i"
              style="margin-right: 0.5rem;"
            >
              {{ i+1 }}标:{{ v }}
            </view>
          </view>
        </flex>
        <!-- 待开发统计项 -->
        <!-- <flex class="uni-form-item uni-column" justify="space-between">
          <view class="uni-label">未兑奖金额: </view>
          <view class="uni-input-text"></view>
        </flex> -->
        <view class="page-label">{{ getLanguageText('小标中奖统计', AppSetting.language) }}</view>
        <flex class="uni-form-item uni-column" justify="space-between">
          <view class="uni-label">{{ getLanguageText('二位下单节数', AppSetting.language) }}: </view>
          <view class="uni-input-text">{{ twoSingleSectionsOrderNum }}</view>
        </flex>
        <flex class="uni-form-item uni-column" justify="space-between">
          <view class="uni-label">{{ getLanguageText('二位下单金额', AppSetting.language) }}: </view>
          <view class="uni-input-text">￥{{ twoSingleSectionsOrderMoney }}</view>
        </flex>
        <flex class="uni-form-item uni-column" justify="space-between">
          <view class="uni-label">{{ getLanguageText('二位中奖金额', AppSetting.language) }}: </view>
          <view class="uni-input-text">￥{{ twoSingleSectionsWinMoney }}</view>
        </flex>
        <!-- 节数统计列表 -->
        <uni-table class="twoTable" border stripe :emptyText="getLanguageText('暂无数据', AppSetting.language)" style="max-height: 20vh; margin: 0 0 1rem;">
          <uni-tr>
            <uni-th width="60" align="left">
              {{ getLanguageText('标数', AppSetting.language) }}
            </uni-th>
            <uni-th width="60" align="left">{{ getLanguageText('号码', AppSetting.language) }}</uni-th>
            <uni-th width="60" align="left">{{ getLanguageText('节数', AppSetting.language) }}</uni-th>
            <uni-th width="70" align="left">{{ getLanguageText('金额', AppSetting.language) }}</uni-th>
          </uni-tr>
          <uni-tr 
            v-for="(item, index) in twoTable" :key="index"
          >
            <uni-td>{{ item['标数'] }}标</uni-td>
            <uni-td>{{ item['号码'] }}</uni-td>
            <uni-td>{{ item['节数'] }}</uni-td>
            <uni-td>￥{{ item['金额'] }}</uni-td>
          </uni-tr>
        </uni-table>
        <view class="page-label">{{ getLanguageText('大标中奖统计', AppSetting.language) }}</view>
        <flex class="uni-form-item uni-column" justify="space-between">
          <view class="uni-label">{{ getLanguageText('四位下单节数', AppSetting.language) }}: </view>
          <view class="uni-input-text">{{ fourSingleSectionsOrderNum }}</view>
        </flex>
        <flex class="uni-form-item uni-column" justify="space-between">
          <view class="uni-label">{{ getLanguageText('四位下单金额', AppSetting.language) }}: </view>
          <view class="uni-input-text">￥{{ fourSingleSectionsOrderMoney }}</view>
        </flex>
        <flex class="uni-form-item uni-column" justify="space-between">
          <view class="uni-label">{{ getLanguageText('四位中奖金额', AppSetting.language) }}: </view>
          <view class="uni-input-text">￥{{ fourSingleSectionsWinMoney }}</view>
        </flex>
        <!-- 中奖号码 -->
        <!-- {{ this.orderSelectList.winningNumber }} -->
        <uni-table class="fourTable" border stripe :emptyText="getLanguageText('暂无数据', AppSetting.language)" style="max-height: 20vh">
          <uni-tr>
            <uni-th width="60" align="left">
              {{ getLanguageText('标数', AppSetting.language) }}
            </uni-th>
            <uni-th width="60" align="left">4位</uni-th>
            <uni-th width="60" align="left">3位</uni-th>
            <uni-th width="60" align="left">2位</uni-th>
            <uni-th width="60" align="left">1位</uni-th>
            <uni-th width="70" align="left">{{ getLanguageText('金额', AppSetting.language) }}</uni-th>
          </uni-tr>
          <uni-tr 
            v-for="(item, index) in fourTable" :key="index"
          >
            <uni-td>{{ item['标数'] }}标</uni-td>
            <uni-td>{{ item['4位'] }}</uni-td>
            <uni-td>{{ item['3位'] }}</uni-td>
            <uni-td>{{ item['2位'] }}</uni-td>
            <uni-td>{{ item['1位'] }}</uni-td>
            <uni-td>￥{{ item['金额'] }}</uni-td>
          </uni-tr>
        </uni-table>
        <!-- 订单列表 -->
        <!-- <pre>{{ orderList }}</pre> -->
      </view>
      <view class="page-nav" v-else>
        {{ getLanguageText('请先在设置页面完成本期的中奖录入，中奖统计方能正常计算', AppSetting.language) }}
      </view>
    </template>

    <!-- <comTabBar label="统计" /> -->
    <view class="comTabBar">
      <view 
        class="tab-item"
        :class="{
          'tab-item-select': data.label == label
        }"
        direction="column"
        v-for="(data, key) in tabList" :key="key"
        @click="goPage(data)"
      >
        <i class="iconfont" :class="data.icon"></i>
        <view class="label">{{ getLanguageText(data.label, AppSetting.language) }}</view>
      </view>
    </view>
  </view>
</template>
<script>
import { 
  getAppSetting,
  getOrderList, 
  getOrderSetting
} from '../../utils/appStorage'
import { getLanguageText } from '../../utils/language'

export default {
  name: "statistics",
  data() {
    return {
      label: '统计',
      tabselect: 1,
      tabList: [
        {
          label: "下单",
          icon: 'icon-bianji',
          path: '/pages/index/index'
        },
        {
          label: "列表",
          icon: 'icon-liebiao',
          path: '/pages/orderList/orderList'
        },
        {
          label: "已售",
          icon: 'icon-youhuiquan',
          path: '/pages/sold/sold'
        },
        {
          label: "统计",
          icon: 'icon-caiwuzhongxin',
          path: '/pages/statistics/statistics'
        },
        {
          label: "设置",
          icon: 'icon-shezhi',
          path: '/pages/setting/setting'
        }
      ],
      AppSetting: {},
      OrderSetting: {},
      // 历史下单数据
      OrderStatisticsList: [],
      search: {
        periodsNum: ''
      },
      twoTable: [],
      fourTable: [],
      // top
      fontsize: 12,
      statusBar: 0, //状态栏高度
      customBar: 0, // 状态栏高度 + 导航栏高度  
      navbar: 0, // 自定义标题与胶囊对齐高度
      // bottom
      twoSingleSectionsWinMoney: 0,
      fourSingleSectionsWinMoney: 0,
    };
  },
  components: {},
  onLoad() {
    this.tableInit()
    getAppSetting(data => {
      this.AppSetting = data
      // 切换至当前期数 统计
      this.search.periodsNum = parseInt(this.AppSetting.periodsNum) > 1 ? parseInt(this.AppSetting.periodsNum) - 1 : this.AppSetting.periodsNum
    })
    getOrderSetting(data => {
      this.OrderSetting = data
      // 中奖统计计算
      // this.winningNumberRuleDataInit()
    })
    this.OrderStatisticsInit()
    // top
    uni.getSystemInfo({
      success: (e) => {
        // this.compareVersion(e.SDKVersion, '2.5.0')
        
        // #ifdef MP
        this.statusBar = e.statusBarHeight
        this.customBar = e.statusBarHeight + 45
        if (e.platform === 'android') {
          this.$store.commit('SET_SYSTEM_IOSANDROID', false)
          this.customBar = e.statusBarHeight + 50
        }
        // #endif
        
        
        // #ifdef MP-WEIXIN
        this.statusBar = e.statusBarHeight
        const custom = wx.getMenuButtonBoundingClientRect()
        this.customBar = custom.bottom + custom.top - e.statusBarHeight

        this.navbar = (custom.top - e.statusBarHeight) * 2 + custom.height
        // #endif

        // #ifdef MP-ALIPAY
        this.statusBar = e.statusBarHeight
        this.customBar = e.statusBarHeight + e.titleBarHeight
        // #endif

        // #ifdef APP-PLUS
        // console.log('app-plus', e)
        this.statusBar = e.statusBarHeight
        this.customBar = e.statusBarHeight + 45
        // #endif

        // #ifdef H5
        this.statusBar = 0
        this.customBar = e.statusBarHeight + 45
        // #endif
      }
    })
    this.remInit()
    // bottom
    // setTimeout(() => {
    //   this.twoSingleSectionsWinMoneyInit()
    //   this.fourSingleSectionsWinMoneyInit()
    // }, 600)
  },
  computed: {
    orderList() {
      let list = []
      // 历史记录
      this.OrderStatisticsList.map(orderStatistics => {
        if (
          !this.search.periodsNum || 
          this.search.periodsNum === orderStatistics.periodsNum
        ) {
          // 按订单维度
          list = [
            ...list,
            ...orderStatistics.orderLists.filter(
              // (item, i) => {return (!item.del && i == 1)}
              (item) => { return !item.del }
            ).map(item => {
              // 订单总金额
              item.money = 0
              // 大标金额
              item.orderNumFour = item.orderNumFour.map(v => {
                let money = v.quantity * this.OrderSetting.quantityPrice_1
                item.money += money
                v.money = money
                return v
              })
              // 小标金额
              item.orderNumTwo = item.orderNumTwo.map(v => {
                let money = v.quantity * this.OrderSetting.quantityPrice_2
                item.money += money
                v.money = money
                return v
              })
              return item
            })
          ]
        }
      })
      return list
    },
    
    // 下单列表
    // 二位
    twoSingleSectionsList() {
      let list = []
      for (let i = 0; i < this.orderList.length; i++) {
        const e = this.orderList[i]
        list = [ ...list, ...e.orderNumTwo ]
      }
      return list
    },
    // 4位
    fourSingleSectionsList() {
      let list = []
      for (let i = 0; i < this.orderList.length; i++) {
        const e = this.orderList[i]
        list = [ ...list, ...e.orderNumFour ]
      }
      return list
    },

    // 金额计算
    twoSingleSectionsOrderMoney() {
      let data = 0
      this.twoSingleSectionsList.forEach(item => {
        data += parseFloat(item.money)
      })
      return data
    },
    
    fourSingleSectionsOrderMoney() {
      let data = 0
      this.fourSingleSectionsList.forEach(item => {
        data += parseFloat(item.money)
      })
      return data
    },

    // 下单节数统计
    twoSingleSectionsOrderNum() {
      let data = 0
      this.twoSingleSectionsList.forEach(item => {
        // console.log('twoSingleSectionsOrderNum###############', item)
        data += parseInt(item.quantity)
      })
      return data
    },

    fourSingleSectionsOrderNum() {
      let data = 0
      this.fourSingleSectionsList.forEach(item => {
        data += parseInt(item.quantity)
      })
      return data
    },

    periodsNumRange() {
      let rang = []
      this.OrderStatisticsList.map(v => {
        rang.push({
          value: v.periodsNum,
          text: `第${v.periodsNum}期`
        })
      })
      return rang
    },

    // 筛选出当前选中订单数据
    orderSelectList() {
      if (this.search.periodsNum !== this.AppSetting.periodsNum) {
        // 往期数据
        return this.OrderStatisticsList.find( v => v.periodsNum == this.search.periodsNum)
      } else {
        // 当前期数据
        console.log('this.OrderSetting', this.OrderSetting)
        return {
          ...this.OrderStatisticsList.find( v => v.periodsNum == this.search.periodsNum),
          ...this.OrderSetting
        }
      }
    },

  },
  methods: {
    getLanguageText,
    goPage(data) {
      if (data.path) {
        console.log('data---', data.path)
        uni.redirectTo({ url: data.path })
      }
    },
    remInit() {
      let srceenNunber = 19.2	//因设计图是1920所有把设计图分为19.2份，所以html字体大小为100px
      let that = this
      
      //窗体改变大小触发事件
      uni.onWindowResize((res) => {
        // console.log('变化后的窗口宽度=' ,res.size.windowWidth)
        that.fontsize = parseFloat(res.size.windowWidth)/srceenNunber
      })
      
      //打开获取屏幕大小
      uni.getSystemInfo({
        success(res) {
          // console.log('设备信息：',res)
          that.fontsize = res.screenWidth/srceenNunber
          // console.log('字体大小：',that.fontsize)
        }
      })
    },
    tableInit() {
      this.twoTable = [
        {
          '标数': 1,
          '号码': '',
          '节数': 0,
          '金额': 0,
        },
        {
          '标数': 2,
          '号码': '',
          '节数': 0,
          '金额': 0,
        },
        {
          '标数': 3,
          '号码': '',
          '节数': 0,
          '金额': 0,
        },
      ]
      this.fourTable = [
        {
          '标数': 1,
          '4位': 0,
          '3位': 0,
          '2位': 0,
          '1位': 0,
          '金额': 0,
        },
        {
          '标数': 2,
          '4位': 0,
          '3位': 0,
          '2位': 0,
          '1位': 0,
          '金额': 0,
        },
        {
          '标数': 3,
          '4位': 0,
          '3位': 0,
          '2位': 0,
          '1位': 0,
          '金额': 0,
        },
      ]
    },
    // 中奖统计计算
    winningNumberRuleDataInit() {
      // console.log('winningNumberRuleDataInit-------')
      // this.orderListInit()
    },
    // 期数数据初始化
    OrderStatisticsInit() {
      uni.getStorage({
        key: 'OrderStatistics',
        success: (res) => {
          this.OrderStatisticsList = [
            ...this.OrderStatisticsList,
            ...res.data.map(v => {
              return v
            })
          ]
        }
      })
      // 拼接当前期数数据
      getOrderList(data => {
        this.OrderStatisticsList.push({
          orderList: data,
          periodsNum: this.AppSetting.periodsNum,
          drawingDate: this.OrderSetting.drawingDate,
          orderAmount: ''
        })
        this.twoSingleSectionsWinMoneyInit()
        this.fourSingleSectionsWinMoneyInit()
      })
    },

    periodsNumChange(v) {
      this.search.periodsNum = v
      // this.winningNumberRuleDataInit()
    },

    // 订单列表数据初始化
    orderListInit() {
      let list = []
      this.OrderStatisticsList.map(orderStatistics => {
        if (
          !this.search.periodsNum || 
          this.search.periodsNum === orderStatistics.periodsNum
        ) {
          list = [
            ...list,
            ...orderStatistics.orderList
          ]
        }
      })
      console.log('orderListInit---', this.orderList)
      this.orderList = list
    },

    // 中奖判断
    winFilter(type, ruleType, winningNumber, orderNum, money) {
      // 中奖规则
      let winningNumberRule = [
        [
          1 * 56, // 小标对后两位
          1 * 2000, // 大标4位全对
          1 * 50, // 大标中前3 或者 后3
          1 * 3, // 大标，小标 中 前后两位
          1 * 1 // 中最后一位
        ],
        [
          1 * 12, // 小标对后两位
          1 * 600, // 大标4位全对
          1 * 20, // 大标中前3 或者 后3
          1 * 2, // 大标，小标 中 前后两位
          0 // 中最后一位
        ],
        [
          1 * 8, // 小标对后两位
          1 * 300, // 大标4位全对
          1 * 10, // 大标中前3 或者 后3
          1 * 1, // 大标，小标 中 前后两位
          0 // 中最后一位
        ]
      ]
      return new Promise((resolve, reject) => {
        switch (type) {
          // 对后两位
          case 0:
            if (winningNumber.substr(-2, 4) == orderNum) {
              resolve(winningNumberRule[ruleType][type] * money)
            }
            resolve(0)
            break;
            // return 0
          // 大标4位全对
          case 1:
            if (winningNumber == orderNum) {
              resolve(winningNumberRule[ruleType][type] * money)
            }
            resolve(0)
            break;
          // 大标中前3 或者 后3
          case 21:
            if (winningNumber.substr(0, 3) == orderNum) {
              resolve(winningNumberRule[ruleType][2] * money)
            }
            resolve(0)
            break;
          case 22:
            if (winningNumber.substr(-3, 3) == orderNum) {
              resolve(winningNumberRule[ruleType][2] * money)
            }
            resolve(0)
            break;
          // 大标，小标 前后两位
          case 31:
            if (winningNumber.substr(0, 2) == orderNum) {
              resolve(winningNumberRule[ruleType][3] * money)
            }
            resolve(0)
            break;
          case 32:
            if(winningNumber.substr(2, 2) == orderNum) {
              resolve(winningNumberRule[ruleType][3] * money)
            }
            resolve(0)
            break;
          // 中最后一位
          case 4:
            console.log('winFilter2---4', winningNumber, orderNum)
            if (winningNumber.substr(-1, 4) == orderNum) {
              resolve(winningNumberRule[ruleType][type] * money)
            }
            resolve(0)
            break;
          default:
            resolve(0)
            break;
        }
      })
    },

    // 大标
    fourSingleSectionsWinMoneyInit() {
      let moneyWin = 0 // 奖金
      for (let i = 0; i < this.orderSelectList.winningNumber.length; i++) {
        // 开奖号码
        const winningNumber = this.orderSelectList.winningNumber[i];
        // console.log('winningNumber--------', winningNumber)
        this.fourTable[i]['号码'] = winningNumber
        for (let i2 = 0; i2 < this.orderList.length; i2++) {
          // console.log('winFilter------i', i2)
          const { orderNumFour } = this.orderList[i2];
          orderNumFour.forEach(async e => {
            // 号码，节数，金额
            const { orderNum, quantity, money } = e
            let winFilter2 = 0
            let winFilter3_1 = 0
            let winFilter3_2 = 0
            let winFilter4_1 = 0
            let winFilter4_2 = 0
            let winFilter5 = 0
            let check = false

            // 大标4位全对
            winFilter2 = await this.winFilter(1, i, winningNumber, orderNum, money)
            if (winFilter2) {
              check = true
              moneyWin += winFilter2
              this.fourTable[i]['4位'] += parseInt(quantity)
              this.fourTable[i]['金额'] += winFilter2
            }

            // 大标中前3 或者 后3
            if (!check) {
              winFilter3_1 = await this.winFilter(21, i, winningNumber, orderNum.substr(0, 3), money)
              winFilter3_2 = await this.winFilter(22, i, winningNumber, orderNum.substr(-3, 3), money)
            }
            if (winFilter3_1 || winFilter3_2) {
              check = true
              moneyWin += winFilter3_1
              moneyWin += winFilter3_2
              this.fourTable[i]['3位'] += parseInt(quantity)
              this.fourTable[i]['金额'] += winFilter3_1
              this.fourTable[i]['金额'] += winFilter3_2
            }
            
            // 大标 中 前后两位
            if (!check) {
              if (i == 0) {
                winFilter4_1 = await this.winFilter(31, i, winningNumber, orderNum.substr(0, 2), money)
              }
              winFilter4_2 = await this.winFilter(32, i, winningNumber, orderNum.substr(2, 2), money)
            }
            if (winFilter4_1) {
              check = true
              moneyWin += winFilter4_1
              this.fourTable[i]['2位'] += parseInt(quantity)
              this.fourTable[i]['金额'] += winFilter4_1
            }
            if (winFilter4_2) {
              check = true
              moneyWin += winFilter4_2
              this.fourTable[i]['2位'] += parseInt(quantity)
              this.fourTable[i]['金额'] += winFilter4_2
            }
            // 中最后一位
            // if (!check && i== 0 && orderNum == winningNumber) {
            if (!check && i== 0) {
              winFilter5 = await this.winFilter(4, i, winningNumber, orderNum.substr(-1, 4), money)
            }
            if (winFilter5) {
              moneyWin += winFilter5
              this.fourTable[i]['1位'] += parseInt(quantity)
              this.fourTable[i]['金额'] += winFilter5
            }

            // console.log('-----------------------------------------------------')
            // console.log(`${i+1}标--${winningNumber}`+'大标--4位全对','下单号码：'+orderNum,'购买金额：'+money,'中奖金额：'+winFilter2)
            // console.log(`${i+1}标--${winningNumber}`+'大标--中前3','下单号码：'+orderNum,'购买金额：'+money,'中奖金额：'+winFilter3_1)
            // console.log(`${i+1}标--${winningNumber}`+'大标--中后3','下单号码：'+orderNum,'购买金额：'+money,'中奖金额：'+winFilter3_2)
            // console.log(`${i+1}标--${winningNumber}`+'大标--中前两位','下单号码：'+orderNum,'购买金额：'+money,'中奖金额：'+winFilter4_1)
            // console.log(`${i+1}标--${winningNumber}`+'大标--中后两位','下单号码：'+orderNum,'购买金额：'+money,'中奖金额：'+winFilter4_2)
            // console.log(`${i+1}标--${winningNumber}`+'大标--中最后一位','下单号码：'+orderNum,'购买金额：'+money,'中奖金额：'+winFilter5)
            // console.log('-----------------------------------------------------')

          })
        }
      }
      return setTimeout(() => {
        console.log('大标 中奖金额----', moneyWin)
        this.fourSingleSectionsWinMoney =  moneyWin
      }, this.orderList.length * 100)
    },

        // 中奖计算
    // 小标
    twoSingleSectionsWinMoneyInit() {
      let moneyWin = 0 // 奖金
      console.log('this.orderSelectList---', this.orderSelectList)
      for (let i = 0; i < this.orderSelectList.winningNumber.length; i++) {
        // 开奖号码
        const winningNumber = this.orderSelectList.winningNumber[i]
        this.twoTable[i]['号码'] = winningNumber.substr(-2, 4)
        for (let i2 = 0; i2 < this.orderList.length; i2++) {
          const { orderNumTwo } = this.orderList[i2];
          orderNumTwo.forEach(async e => {
            // 号码，节数，金额
            const { orderNum, quantity, money } = e
            let winFilter1 = 0
            // 对后两位
            winFilter1 = await this.winFilter(0, i, winningNumber, orderNum, money)
            moneyWin += winFilter1
            // console.log('小标--对后两位',orderNum,winFilter1)
            // 节数统计列表
            if (winFilter1) {
              this.twoTable[i]['节数'] += parseInt(quantity)
              this.twoTable[i]['金额'] += winFilter1
            }
          })
        }
      }
      // console.log('小标 中奖金额----', moneyWin)
      // return moneyWin
      return setTimeout(() => {
        console.log('大标 中奖金额----', moneyWin)
        this.twoSingleSectionsWinMoney =  moneyWin
      }, this.orderList.length * 100)
    },
  }
};
</script>
<style lang="scss" scoped>
.page-statistics {
  .expalin {
    font-size: 0.7rem;
    color: #747474;
  }
  .uni-input-text {
    width: 10rem;
  }
}
.topBar {
  background: #fff;
  border-bottom: 1px solid #e7e7e7;
  line-height: 2.2rem;
  .title-nav {
    background: #fff;
    border-bottom: 1px solid #e7e7e7;
    line-height: 2.2rem;
    position: fixed;
    top: 0;
    text-align: center;
    font-size: 0.8rem;
    font-weight: bold;
    width: calc(100% - 1rem);
    padding: 0 0.5rem;
    z-index: 10;
  }
}
.comTabBar {
  display: flex;
  justify-content: space-between;
  border-radius: 0.8rem 0.8rem 0 0;
  // border-top: 1px solid #dedede;
  box-shadow: rgba(176, 176, 176, 0.35) 0rem 0.1rem 0.5rem;
  position: fixed;
  bottom: 0;
  padding: 0.3rem 1.5rem 0.25rem;
  width: calc(100% - 3rem);
  color: #525252;
  background: #fff;
  .tab-item {
    .iconfont {
      margin: 0.1rem 0;
      font-size: 1.2rem;
    }
    .label {
      font-size: 0.6rem;
    }
  }
  .tab-item-select {
    color: #409EFF;
    .iconfont {
      color: #409EFF;
    }
  }
}
.optionBar {
  display: flex;
  padding: 0.1rem 0.2rem;
  font-size: 0.6rem;
  .optionItem {
    margin-right: 0.6rem;
    padding: 0.2rem 0.6rem;
    border-radius: 0.2rem;
  }
  .select {
    background: #409EFF;
    color: #fff;
  }
}

.tab-bar {
  padding: 0.2rem 2.5rem 0.5rem;
  width: calc(100% - 5rem);
  .tab-item {
    width: 3.5rem;
    text-align: center;
    line-height: 1.6rem;
    border-bottom: 0.2rem solid #fff;
    &.tabselect {
      border-bottom: 0.2rem solid #409EFF;
    }
  }
}
</style>
